<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Knowledge extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {

        $table = $this->table('knowledge_folder', ['comment' => '知识库文件夹']);
        $table
            ->addColumn('admin_id', 'integer', array('limit' => 30, 'default' => 0, 'comment' => '上传人'))
            ->addColumn('title', 'string', array('limit' => 220, 'null' => true, 'comment' => '标题'))
            ->addTimestamps()
            ->addSoftDelete()
            ->create();

        $table = $this->table('knowledge', ['comment' => '知识库']);
        $table
            ->addColumn('admin_id', 'integer', array('limit' => 30, 'default' => 0, 'comment' => '上传人'))
            ->addColumn('knowledge_folder_id', 'integer', array('limit' => 30, 'default' => 0, 'comment' => '文件夹id'))
            ->addColumn('title', 'string', array('limit' => 120, 'null' => true, 'comment' => '标题'))
            ->addColumn('path', 'string', array('limit' => 220, 'null' => true, 'comment' => '文件路径'))
            ->addColumn('hash', 'string', array('limit' => 220, 'null' => true, 'comment' => '文件hash值'))
            ->addColumn('size', 'integer', array('limit' => 30, 'default' => 0, 'comment' => '文件大小'))
            ->addColumn('domain_port', 'string', array('limit' => 50, 'null' => true, 'comment' => '域名:端口/ghpt_img'))
            ->addColumn('suffix', 'string', array('limit' => 20, 'null' => true, 'comment' => '文件后缀'))
            ->addColumn('type', 'string', array('limit' => 120, 'null' => true, 'comment' => '文件类型'))
            ->addColumn('status', 'boolean',array('limit' => 1, 'default' => 1, 'comment' => '状态(1or2,开启or关闭)'))
            ->addTimestamps()
            ->addSoftDelete()
            ->create();
    }
}
